let baseUrl = "http://localhost/H5-2003/vmall.com";//基础路径必须是绝对路径

define(['jquery'], function($) {
    return {
        render: function() {
            $.ajax({
                type: "get",
                url: `${baseUrl}/interface/model/getall.php`,
                dataType: "json",
                success: function(res) {
                    console.log(res);
                    let temp = '';
                    res.forEach(elm => {
                        
                        let pic = JSON.parse(elm.pic);
                        // console.log(pic);
                        temp += ` <li>
                        <a href="${baseUrl}/src/html/news.html?id=${elm.id}">
                            <span>
                            </span>
                            <div class="img">
                                <img src="${baseUrl}/src/${pic[0].src}" alt="${baseUrl}/src/${pic[0].title}">
                            </div>
                            <p>${elm.title}</p>
                            <p>${elm.dateils}</p>
                            <p>${elm.price}</p>
                        </a>
                    </li>`;
                    });

                    $('.list').html(temp);

                }
            });
        }
    }
});
